package com.szc.fs.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;


/**
 * @Description 获取参数工具类
 * @Date 18:10 2022/12/26
 * @Param
 * @return
 **/
public class PropertiesUtil {
    static Properties properties = new Properties();

    // 放在静态类中 只加载一次
    static {
        try {
            InputStream resourceAsStream = PropertiesUtil.class.getClassLoader().getResourceAsStream("config.properties");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(resourceAsStream, "UTF-8"));
            properties.load(bufferedReader);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 构建一个通用的方法来获取 配置文件key 对应的value
     */

    public static String getConfig(String key) {
        return  (String) properties.get(key);
    }



}
